home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / libq / IIgettup.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-05-30  |  1.8 KB  |  102 lines

  1. # include    <ingres.h>
  2. # include    <symbol.h>
  3. # include    "IIglobals.h"
  4. # include    <sccs.h>
  5. # include    <errors.h>
  6.  
  7. SCCSID(@(#)IIgettup.c    8.3    5/30/88)
  8.  
  9.  
  10. /*
  11. **    IIgettup is called to retrieve one instance
  12. **    of the target list into the c-variables.
  13. **
  14. **    Integers and Floating point numbers can be converted
  15. **    to other numbers.
  16. **
  17. **    Characters fields must match other character fields.
  18. */
  19.  
  20. IIgettup(file_name, line_no)
  21. char    *file_name;
  22. int    line_no;
  23. {
  24.     register int        length, domain;
  25.     register struct retsym    *ret;
  26.     struct retsym        sym;
  27.     char            temp[256], *IIitos(), *s;
  28.  
  29.  
  30.  
  31.     if (IIproc_name = file_name)
  32.         IIline_no = line_no;
  33.  
  34.     while (IIpb.pb_type != PB_REG)
  35.     {
  36.         IIreadinput(&IIpb);
  37.         if (bitset(IIpb.pb_stat, PB_INFO))
  38.             IIpb_prime(&IIpb, PB_NOTYPE);
  39.         else
  40.             return (0);
  41.     }
  42.  
  43.     if (IIerrflag)
  44.         return (0);    /* error. no data will be coming */
  45.  
  46.     ret = IIretsym;
  47.     domain = 0;
  48.  
  49.     for (;;)
  50.     {
  51.         if (IIpb_get(&IIpb, &sym, 2) != 2)
  52.             IIsyserr("IIgettup bad rdpipe 1");
  53.         if (length = sym.len & 0377)
  54.             if (IIpb_get(&IIpb, temp, length) != length)
  55.                 IIsyserr("IIgettup bad rdpipe-2 %d", length);
  56. #        ifdef xETR1
  57.         if (IIdebug)
  58.         {
  59.             printf("%s ent ", IIproc_name ? IIproc_name : "");
  60.             printf("gettup type %d len %d\n", sym.type, length);
  61.         }
  62. #        endif
  63.         domain++;
  64.         switch (sym.type)
  65.         {
  66.  
  67.           case INT:
  68.           case FLOAT:
  69.             if (ret->type == CHAR)
  70.             {
  71.                 s = IIitos(domain);
  72.                 IIerror(NUMINTOCHAR, 1, &s);
  73.                 return (0);
  74.             }
  75.             if (IIconvert(temp, ret->addr, sym.type, length, ret->type, ret->len & 0377) < 0)
  76.             {
  77.                     s = IIitos(domain);
  78.                     IIerror(NUMOVFLO, 1, &s);
  79.             }
  80.             break;
  81.  
  82.           case CHAR:
  83.             if (ret->type != CHAR)
  84.             {
  85.                 s = IIitos(domain);
  86.                 IIerror(CHARINTONUM, 1, &s);
  87.                 return (0);
  88.             }
  89.             IIbmove(temp, ret->addr, length);
  90.             ret->addr[length] = '\0';    /* null terminate string */
  91.             break;
  92.  
  93.           case EOTUP:
  94.             return (1);
  95.  
  96.           case EXIT:
  97.             return (0);
  98.         }
  99.         ret++;
  100.     }
  101. }
  102.